<template>
<view class="payModeBox box">
  <view class="title flex a-item">支付方式</view>
  <view @tap="setPayType(item)" v-for="item in payModeList" class="payType flex flex-row flex  a-item">
    <image :src="item.remark" />
    <view class="name flex a-item">
      {{ item.label }}
    </view>
    <radio  class="radio" style="transform:scale(0.7)" value="cb" :checked="payType === item.value" />
  </view>
</view>
</template>

<script>
import {getDict} from "../service/api/shopping";
import {getUserInfo} from "../service/auth";
export default {
  name: "payMode",
  props:{
    payType: {
      type: [Number,String],
      default:0
    },
  },
  data(){
    return{
      payModeList:[
        // {name:'微信支付',type:0,image:'http://121.41.75.32:8002/file/static/wxPay.png'},
        // {name:'货到付款',type:1,image:'http://121.41.75.32:8002/file/static/transport.png'}
      ]
    }
  },
  created() {
    this.user = JSON.parse(getUserInfo())
    // if (this.user.customerType === 1){
    //   this.payModeList=[
    //       {label:'微信支付',value:'wx',remark:'http://121.41.75.32:8002/file/static/wxPay.png'},
    //       {label:'线上支付',value:'tzb',remark:'http://121.41.75.32:8002/file/static/tzb.png'},
    //   ]
    //   this.$emit('update:payType','wx')
    // }else {
      this.getDict()
    // }
  },
  methods:{
    setPayType(val){
      this.$emit('update:payType',val.value)
    },
    getDict(){
      const data = {
        dictCode:'pay_type'
      }
      getDict(data).catch(res=>{
        if (res.content.length){
          this.$emit('update:payType',res.content[0].value)
          this.payModeList = res.content
        }else {
          uni.navigateBack()
          uni.showToast({
            title:'未配置付款方式请先配置',
            icon:'none'
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.payModeBox{
  background: #ffffff;
  font-family: PingFang SC;
  font-weight: 500;
 .title{
   font-size: 35rpx;
   height: 50rpx;
   margin-bottom: 50rpx;
 }
  .payType{
    height: 80rpx;
    position: relative;
    image{
      width: 60rpx;
      height: 60rpx;
    }
    .name{
      padding-left: 30rpx;
      font-size: 35rpx;
    }
    .radio{
      position: absolute;
      right: 10rpx;

    }
  }
}
</style>
